package basic

import (
	"github.com/gin-gonic/gin"
	"goskeleton/app/service/basic/demo"
	"net/http"
)

func DemoTest(c *gin.Context) {
	todoList, err := demo.DemoTest()
	//s := demo.DemoTestService{}
	//todoList, err := s.DemoTest()
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
	} else {
		c.JSON(http.StatusOK, gin.H{
			"code": 200,
			"msg":  "success",
			"data": todoList,
		})
	}
}

func ChangeDb(c *gin.Context) {
	ds, _ := c.GetQuery("ds")
	flag, err := demo.ChangeDb(ds)
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
	} else {
		c.JSON(http.StatusOK, gin.H{
			"code": 200,
			"msg":  "success",
			"data": flag,
		})
	}
}
